package com.yanqu.road.server.cmd.banquet;

import com.yanqu.road.pb.banquet.BanquetProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.banquet.BanquetModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

//@Cmd(code = Protocol.S_BANQUET_FEAST_GET_REWARD, desc = "获取本服盛宴的人气礼")
public class GetBanquetFeastRewardCmd extends AbstractCommand {

	private String banquetId;
	private int rewardId;
	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		BanquetProto.BanquetGetPopRewardReq reqMsg = BanquetProto.BanquetGetPopRewardReq.parseFrom(packet.getBytes());
		banquetId = reqMsg.getBanquetId();
		rewardId = reqMsg.getRewardId();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ret = player.getModule(BanquetModule.class).getUserBanquetFeastReward(banquetId,rewardId);
	}

	@Override
	public void sendData(GamePlayer player) {
		BanquetProto.BanquetGetPopRewardResp.Builder respMsg = BanquetProto.BanquetGetPopRewardResp.newBuilder();
		respMsg.setRet(ret);
		player.sendPacket(Protocol.U_BANQUET_FEAST_GET_REWARD, respMsg);
	}
}
